<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.hilaver.dzmis.Constants" %>
<%@ page import="com.hilaver.dzmis.service.impl.CtServiceImpl" %>
<%@ page import="com.hilaver.dzmis.service.impl.ProcurementServiceImpl" %>
<%@ page import="com.hilaver.dzmis.service.impl.I18nServiceImpl" %>
<%@ page import="com.hilaver.dzmis.service.impl.BiPantoneColorServiceImpl" %>
<%@ page import="com.hilaver.dzmis.codetable.*" %>
<%@ page import="com.hilaver.dzmis.product.ProductYarn" %>
<%@ page import="com.hilaver.dzmis.procurement.Procurement" %>
<%@ page import="com.hilaver.dzmis.product.ProductIdentification" %>
<%@page import="com.hilaver.dzmis.service.impl.CtServiceImpl"%>
<%@page import="com.hilaver.dzmis.basicinfo.BiFranceCustomer"%>
<%
	Integer id = Integer.parseInt(request.getParameter("id"));
	CtServiceImpl cs = new CtServiceImpl();
	ProcurementServiceImpl ps = new ProcurementServiceImpl();
	I18nServiceImpl i18n = new I18nServiceImpl();
	BiPantoneColorServiceImpl pcService = new BiPantoneColorServiceImpl();
	Locale locale = (Locale) request.getSession().getAttribute(
			Constants.SESSION_LOCALE);
	ps.setLocale(locale);
	Procurement procurement = ps.getObj(id);
	
	List<ProductYarn> pyList = ps.getYarn(id);
	Set<ProductIdentification> piSet = procurement.getProductIndentifications();
	List<BiFranceCustomer> fcList = ps.getDiffFranceCustomerFrom(piSet);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
<link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
<title><%=procurement.getName()%>--<%=i18n.getShortMessage(locale, "ui.procurement.useryarn") %></title>
</head>
<body>
<table cellspacing="0" id="the-table" style="width: 100%;">
	<tr>
		<td style="background:#eeeeee; text-align: center;" colspan="<%=pyList.size() + 2 %>">
			<b><%=procurement.getName() %></b>
		</td>
	</tr>
	<tr>
		<td style="text-align: center; width: 160px;">
			<b><%=i18n.getShortMessage(locale, "ui.francecustomer.name") %></b>
		</td>
		<%for(ProductYarn py : pyList){ %>
			<td style="text-align: center;">
				<b><%=py.getBiYarn().getReference() %>&nbsp;&nbsp;<%=cs.getDescription(CtMaterialType.class.getName(), py.getBiYarn().getCtMaterialType(), locale) %></b>
			</td>
		<%} %>
		<td style="text-align: center;" class="x-grid3-td-total">
			<b><%=i18n.getShortMessage(locale, "message.list.total") %>(Kg)</b>
		</td>
	</tr>
	<%for(BiFranceCustomer fc : fcList) {%>
		<tr>
			<td style="text-align: center;">
				<b><%=fc.getName() %>--<%=fc.getDepartment()==null?"":fc.getDepartment() %></b>
			</td>
			<%for(ProductYarn py : pyList){ %>
			<td style="text-align: center;">
				<%=ps.getTotalWeightFrom(piSet, fc, py) %>
			</td>
			<%} %>
			<td style="text-align: center;" class="x-grid3-td-total">
				<%=ps.getTotalWeightFrom(piSet, fc) %>
			</td>
		</tr>
	<%}%>
	<tr>
		<td style="text-align: right;">
			<b><%=i18n.getShortMessage(locale, "message.list.total") %>(Kg)</b>&nbsp;&nbsp;&nbsp;&nbsp;
		</td>
		<%for(ProductYarn py : pyList){ %>
		<td style="text-align: center;" class="x-grid3-summary-row">
			<%=ps.getTotalWeightFrom(piSet, py) %>
		</td>
		<%} %>
		<td style="text-align: center;" class="x-grid3-total">
			<%=ps.getTotalWeightFrom(piSet) %>
		</td>
	</tr>	
</table>
</body>
</html>